#!/bin/sh



rsync -avzP /tmp/test/*  -e ssh  192.168.191.250:/tmp/test/

file=/tmp/test/1

#localfile=`hostname && md5sum $file`

ssh 192.168.191.250 "if [ -f $file ];then hostname && md5sum $file;else echo "NO file  $file"; fi"
#ssh 192.168.191.250 "if [ -f $file ];then echo "$(hostname) $(md5sum $file)" ;else echo "NO file  $file"; fi"
#remotfile=`ssh 192.168.191.250 "if [ -f /tmp/test/1 ];then hostname && md5sum /tmp/test/1 ;else hostname && echo "NO file  /tmp/test/1"; fi"`
#ssh 192.168.191.250 "md5sum $file"

echo "$localfile $remotfile "

remote_ssh(){

	case $1 in 
			file)
   			ssh 192.168.191.250 "if [ -f $2 ];then md5sum $2 ;else echo "NO file  $2"; fi" 
			;;
			folder)
			ssh 192.168.191.250 "if [ -d $2 ];then echo "folder $2" ;else echo "NO folder $2"; fi" 
			;;
			*)
			echo "input error"
			;;
	esac
}

#remote_ssh $file

foreachd(){

for f in $1/*
do
	if [ -d $f ];then
    	
		echo "folder $f"        >> /tmp/test.`date +%F-%H%M`
    	remote_ssh folder $f    >> /tmp/test.`date +%F-%H%M`
		foreachd $f
       
	else

    	echo "file $f "         >> /tmp/test.`date +%F-%H%M`
		/usr/bin/md5sum $f      >> /tmp/test.`date +%F-%H%M`
		remote_ssh file $f      >> /tmp/test.`date +%F-%H%M`
		
	fi

done

}

foreachd $1
